const express = require('express');
const router = express.Router();
const knowledgeController = require('../controllers/knowledge.controller.js');
const { verifyToken, isAdmin } = require('../middleware/auth.middleware.js');

router.get('/', knowledgeController.getAllKnowledge);
router.get('/:id', knowledgeController.getKnowledgeById);
router.post('/', verifyToken, isAdmin, knowledgeController.createKnowledge);
router.put(
  '/:knowledgeId',
  verifyToken,
  isAdmin,
  knowledgeController.updateKnowledge
);
router.delete(
  '/:knowledgeId',
  verifyToken,
  isAdmin,
  knowledgeController.deleteKnowledge
);
router.post(
  '/:knowledgeId/like',
  verifyToken,
  knowledgeController.likeKnowledge
);
router.delete(
  '/:knowledgeId/like',
  verifyToken,
  knowledgeController.unlikeKnowledge
);
router.post(
  '/:knowledgeId/favorite',
  verifyToken,
  knowledgeController.favoriteKnowledge
);
router.delete(
  '/:knowledgeId/favorite',
  verifyToken,
  knowledgeController.unfavoriteKnowledge
);

module.exports = router;
